package com.yuexi.web;

import com.github.binarywang.wxpay.bean.result.WxPayMicropayResult;
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryResult;
import com.github.binarywang.wxpay.bean.result.WxPayOrderReverseResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.yuexi.domain.payment.wxpay.WePayDomain;
import com.yuexi.domain.payment.wxpay.bo.MicropayBO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jie
 * @date 2023/4/6 -14:41
 */
@Api(tags = "微信支付")
@RequestMapping("wepay")
@RestController
public class WePayController {

    @Autowired
    private WePayDomain domain;

    @ApiOperation("micropay")
    @PostMapping("micropay")
    public Object micropay(MicropayBO bo) throws WxPayException {
        WxPayMicropayResult micropay = domain.micropay(bo);
        return micropay;
    }

    @ApiOperation("queryOrder")
    @PostMapping("queryOrder")
    public Object queryOrder(String outTradeNo) throws WxPayException {
        WxPayOrderQueryResult result = domain.queryOrder(outTradeNo);
        return result;
    }

    @ApiOperation("reverseOrder")
    @PostMapping("reverseOrder")
    public Object reverseOrder(String outTradeNo)  throws WxPayException {
        WxPayOrderReverseResult result = domain.reverseOrder(outTradeNo);
        return result;
    }

}
